<?php
    // +----------------------------------------------------------------------
    // | 帮助
    // +----------------------------------------------------------------------
    // | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
    // +----------------------------------------------------------------------
    // | Author: 微尘 <yicmf@qq.com>
    // +----------------------------------------------------------------------
    namespace app\controller\cms;

    use app\event\cms\Document as DocumentEvent;
    use app\model\cms\Category as CategoryModel;

    class Help extends Common
    {

        // 初始化
        protected function initialize()
        {
            parent::initialize();
            // 公告
            //            $this->assign('shadow','<span>公告：<a href="#">D</a></span>');
            // 分类
            $this->assign('open_doc_id',0);
            $categories = CategoryModel::where('status', 1)->where('pid', 11)->order('sort ASC')->select();
            $this->assign('categories', $categories);
        }

        // 帮助中心首页
        public function index()
        {
            return $this->fetch();
        }    // 帮助中心详情

        public function detail()
        {
            $event = new DocumentEvent();
            $result = $event->detail($this->request->param(), $this->user);
            if (0 != $result['code']) {
                $this->error($result['message']);
            } else {
                $this->assign('data', $result['data']);
                $this->assign('open_doc_id',$result['data']['id']);
                return $this->fetch();
            }
        }

        // 搜索
        public function search()
        {
            $good_category = CategoryModel::where('status', 1)->where('is_recommend', 1)->where('pattern_id', 5)->order('sort ASC')->select();
            $this->assign('good_category', $good_category);
            return $this->fetch();
        }
    }
